{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_osy:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## OSY\n",
    "\n",
    "Osyczka and Kundu used the following six-variable\n",
    "test problem: "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Definition**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\begin{equation}\n",
    "\\newcommand{\\boldx}{\\mathbf{x}}\n",
    "\\begin{array}\n",
    "\\mbox{Minimize} & f_1(\\boldx) = -\\left[25(x_1-2)^2+(x_2-2)^2 + (x_3-1)^2+(x_4-4)^2  + (x_5-1)^2\\right], \\\\\n",
    "\\mbox{Minimize} & f_2(\\boldx) = x_1^2 + x_2^2 + x_3^2 + x_4^2 + x_5^2 + x_6^2, \n",
    "\\end{array}\n",
    "\\end{equation}\n",
    "\n",
    "\\begin{equation}\n",
    "\\begin{array}\n",
    "\\mbox{\\text{subject to}} & C_1(\\boldx) \\equiv (x_1 + x_2 - 2) / 2 \\geq 0, \\\\\n",
    "& C_2(\\boldx) \\equiv (6 - x_1 - x_2) / 6 \\geq 0, \\\\\n",
    "& C_3(\\boldx) \\equiv (2 - x_2 + x_1) / 2 \\geq 0, \\\\\n",
    "& C_4(\\boldx) \\equiv (2 - x_1 + 3x_2) / 2 \\geq 0, \\\\\n",
    "& C_5(\\boldx) \\equiv (4 - (x_3-3)^2 - x_4) / 4 \\geq 0, \\\\\n",
    "& C_6(\\boldx) \\equiv ((x_5-3)^2 + x_6 - 4) / 4 \\geq 0, \\\\[2mm]\n",
    "& 0 \\leq x_1,x_2,x_6 \\leq 10,\\quad 1 \\leq x_3,x_5 \\leq 5,\\quad 0\\leq x_4 \\leq 6.\n",
    "\\end{array}\n",
    "\\end{equation}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Optimum**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The Pareto-optimal region is a concatenation of\n",
    "five regions. Every region lies on some of the constraints. However, for the\n",
    "entire Pareto-optimal region, $x_4^{\\ast} = x_6^{\\ast} = 0$. \n",
    "In table below shows the other variable values in each of the five\n",
    "regions and the constraints that are active in each region.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "raw_mimetype": "text/html"
   },
   "source": [
    "<div style=\"text-align: center;\">\n",
    "    <img src=\"https://github.com/anyoptimization/pymoo-data/blob/main/docs/images/pf_osy.png?raw=true\" width=\"450\">\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Plot**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pymoo.problems import get_problem\n",
    "from pymoo.util.plotting import plot\n",
    "\n",
    "problem = get_problem(\"osy\")\n",
    "plot(problem.pareto_front(), no_fill=True)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
